package com.stox.client.ui.javafx.watchlist.widget;

import javafx.event.ActionEvent;

import com.stox.client.ui.javafx.watchlist.view.EditWatchlistConfigurationView;
import com.stox.client.ui.javafx.widget.ConfigurationPopupControl;
import com.stox.client.ui.javafx.workbench.stage.StoxStage;
import com.stox.client.ui.javafx.core.util.CSS;
import com.stox.client.ui.javafx.core.util.UI;
import com.stox.shared.core.i18n.MessageSource;


public class EditWatchlistButton extends AbstractWatchlistButton {
	
	public EditWatchlistButton(WatchlistComboBox watchlistComboBox) {
		super(watchlistComboBox);
		setText(MessageSource.get("Edit"));
		UI.control(this, MessageSource.get("Edit.Watchlist"), true, false, CSS.blue);
	}
	
	@Override
	public void handle(ActionEvent event) {
		EditWatchlistConfigurationView watchlistConfigurationView = new EditWatchlistConfigurationView(getWatchlistComboBox());
		ConfigurationPopupControl configurationPopupControl = new ConfigurationPopupControl(watchlistConfigurationView);
		configurationPopupControl.getApplyButton().setOnAction(watchlistConfigurationView);
		configurationPopupControl.show(StoxStage.INSTANCE);
	}
}
